<include file="Public/head"/>

<body class="no-skin">
<include file="Public/header"/>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <include file="Public/sidebar"/>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <include file="Public/breadcrumbs"/>
            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">
                <include file="Public/set"/>

                <!-- /section:settings.box -->
                <div class="row">
                     <div class="cf">
                            <form class="form-inline" action="" method="get">
                               


                                <label class="inline">回复状态</label>
                                <select name="class_type" id="class_type" class="form-control">
                                    <option value="0">--请选择回复状态--</option>
                                    <option value="2" <if condition=" I('get.status') eq 2 ">selected="selected"</if>>未回复</option>
                                    <option value="1" <if condition=" I('get.status') eq 1 ">selected="selected"</if>>已回复</option>
                                </select>



                               
                                <button type="button" onclick="sou()" class="btn btn-purple btn-sm">
                                    <span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
                                    搜索
                                </button>
                            </form>
                        </div>
                    <div class="space-4"></div>
                      <table class="table table-striped table-bordered">
                            <thead>
                            <tr>
                                <th>ID</th>
                                <th>留言人</th>
                                <th>留言内容</th>
                                <th>留言时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>

                            <?php if($data){
                                foreach($data as $k=>$val){ ?>
                                 <tr>

                                     <td><?php echo $k+1?></td>
                                     <td><?php echo $val['name']?></td>
                                     <td><?php echo $val['content']?></td>
                              
                                     <td><?php echo $val['add_time']?></td>
                                  

                                    <td><if condition=" $val['status'] eq 2 "><a href="javascript:;" class="answer" onclick="answer({$val['user_id']},{$val['uid']},{$val['id']})"><i
                                        class="ace-icon fa fa-pencil  bigger-100 red"></i>回复留言</a><else/><a href="javascript:;" class="answer" ><i
                                        class="ace-icon fa fa-pencil  bigger-100 green"></i>已回复</a></if>&nbsp;&nbsp;
                                        <a href="javascript:;" val="<?php echo U('del',array('id'=>$val['id']));?>" class="del"><i
                                                class="ace-icon fa fa-trash-o bigger-100 red"></i>删除</a>
                                    </td>

                                </tr>
                            </foreach>
                            <?php }}else{echo "<tr align='center'><td colspan='9'>没有留言信息！</td></tr>";}?>
                            </tbody>
                        </table>
                    {$page}
                    <!-- PAGE CONTENT ENDS -->
                </div><!-- /.col -->
            </div><!-- /.row -->
        </div><!-- /.page-content -->
    </div>
</div><!-- /.main-content -->
<include file="Public/footer"/>

</div><!-- /.main-container -->

<include file="Public/footerjs"/>
<script src="__PUBLIC__/layer/layer.js"></script>
<!-- inline scripts related to this page -->
<script type="text/javascript">
    $(".del").click(function () {
            var url = $(this).attr('val');
        //alert(url);
        //return false;
            bootbox.confirm({
                title: "系统提示",
                message: "确定要删除该精彩瞬间吗?",
                callback: function (result) {
                    if (result) {
                        window.location.href = url;
                    }
                },
                buttons: {
                    "cancel": {"label": "取消"},
                    "confirm": {
                        "label": "确定",
                        "className": "btn-danger"
                    }
                }
            });
        });
    function answer(user_id,uid,id){
        layer.open({
            type: 1,
            skin: 'layui-layer-rim', //加上边框
            area: ['420px', '240px'], //宽高
            content: '<form><textarea rows="5" cols="54" placeholder="请输入留言....." id="content"></textarea><button type="button" style="margin-left:175px;" onclick="huifu('+user_id+','+uid+','+id+')" class="btn btn-default navbar-btn">回复评论</button></form>'
          });

    }
    function huifu(user_id,uid,id){
        var content = $('#content').val();
        $.ajax({
            url:"{:U('answer')}",
            type:"get",
            data:{user_id:user_id,uid:uid,content:content,id:id},
            success:function(e){
                if(e==1){
                    layer.alert('回复成功', {
                        skin: 'layui-layer-molv' //样式类名
                        ,closeBtn: 0
                      }, function(){
                          window.location.reload(); 
                      });
                   
                   
                }else if(e==2){
                    layer.msg('请填写回复内容');
                }else{
                    layer.alert('回复失败', {
                        skin: 'layui-layer-molv' //样式类名
                        ,closeBtn: 0
                      }, function(){
                          window.location.reload(); 
                      });
                }
            }
        })
    }
    function sou(){
        var class_type = $('#class_type').val();
        location.href="__APP__/Admin/Teachers/massage/status/"+class_type+".html";
    }
</script>
</body>
</html>
